//app.js
import * as R from 'ramda';
App({
  onLaunch: function () {
    /* if (!wx.cloud) {
      console.error('请使用 2.2.3 或以上的基础库以使用云能力')
    } else {
      wx.cloud.init({
        traceUser: true,
      })
    } */
    const userInfo = wx.getStorageSync('userInfo');
    const token =  wx.getStorageSync('token');
    R.ifElse(
      () => !R.isEmpty(userInfo) && !R.isNil(token),
      R.compose(
        () => this.globalData.userInfo = userInfo,
        () => this.globalData.token = token
      ),
      () => wx.reLaunch({ url: '/pages/login/index' })
    )();
  },
  globalData: {
    token: null,
    userInfo: {
      role: null,
    }
  },
})
